<!--
 * @Description:
 * @Author: 崔堂袁
 * @Date: 2021-05-01 01:33:42
 * @LastEditTime: 2021-05-04 21:53:47
-->
<template>
  <div class="setAttributes">
    <CircleAttributes v-if="selectedModelIndex===model.CIRCLE"
                      ref="CircleAttributes" />
    <PlaneAttributes v-if="selectedModelIndex===model.PLANE"
                     ref="PlaneAttributes" />
    <RingAttributes v-if="selectedModelIndex===model.RING"
                    ref="RingAttributes" />
    <BoxAttributes v-if="selectedModelIndex===model.BOX"
                   ref="BoxAttributes" />
    <SphereAttributes v-if="selectedModelIndex===model.SPHERE"
                      ref="SphereAttributes" />
    <CylinderAttributes v-if="selectedModelIndex===model.CYLINDER"
                        ref="CylinderAttributes" />
    <ConeAttributes v-if="selectedModelIndex===model.CONE"
                    ref="ConeAttributes" />
    <TorusAttributes v-if="selectedModelIndex===model.TORUS"
                     ref="TorusAttributes" />
    <TorusKnotAttributes v-if="selectedModelIndex===model.TORUSKNOT"
                         ref="TorusKnotAttributes" />
  </div>
</template>

<script>
import { ref } from 'vue'
import CircleAttributes from './DiffrentModels/CircleAttributes'
import PlaneAttributes from './DiffrentModels/PlaneAttributes'
import RingAttributes from './DiffrentModels/RingAttibutes'
import BoxAttributes from './DiffrentModels/BoxAttributes'
import SphereAttributes from './DiffrentModels/SphereAttributes'
import CylinderAttributes from './DiffrentModels/CylinderAttributes'
import ConeAttributes from './DiffrentModels/ConeAttributes'
import TorusAttributes from './DiffrentModels/TorusAttributes'
import TorusKnotAttributes from './DiffrentModels/TorusKnotAttributes'
import model from '@/views/0level/modelStyle'
export default {
  components: {
    CircleAttributes,
    PlaneAttributes,
    RingAttributes,
    BoxAttributes,
    SphereAttributes,
    CylinderAttributes,
    ConeAttributes,
    TorusAttributes,
    TorusKnotAttributes
  },
  props: {
    selectedModelIndex: {
      type: Number,
      default: null
    }
  },
  setup (props) {
    const CircleAttributes = ref()
    const PlaneAttributes = ref()
    const RingAttributes = ref()
    const BoxAttributes = ref()
    const SphereAttributes = ref()
    const CylinderAttributes = ref()
    const ConeAttributes = ref()
    const TorusAttributes = ref()
    const TorusKnotAttributes = ref()

    const saveData = () => {
      switch (props.selectedModelIndex) {
        case model.CIRCLE: CircleAttributes.value.saveData(); break
        case model.PLANE: PlaneAttributes.value.saveData(); break
        case model.RING: RingAttributes.value.saveData(); break
        case model.BOX: BoxAttributes.value.saveData(); break
        case model.SPHERE: SphereAttributes.value.saveData(); break
        case model.CYLINDER: CylinderAttributes.value.saveData(); break
        case model.CONE: ConeAttributes.value.saveData(); break
        case model.TORUS: TorusAttributes.value.saveData(); break
        case model.TORUSKNOT: TorusKnotAttributes.value.saveData(); break
        default: console.log('err')
      }
    }

    return {
      model,
      saveData,
      CircleAttributes,
      PlaneAttributes,
      RingAttributes,
      BoxAttributes,
      SphereAttributes,
      CylinderAttributes,
      ConeAttributes,
      TorusAttributes,
      TorusKnotAttributes
    }
  }
}
</script>

<style lang='less' scoped>
.setAttributes {
  width: 100%;
}
</style>
